from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        # nums.sort()
        # # 方法1 双指针  宣告破产 这个要返回的是索引 我找不到索引
        # i ,j = 0,len(nums)-1
        # while i<j:
        #     if nums[i]+nums[j]==target:
        #         return [i,j]
        #     elif nums[i]+nums[j]<target:
        #         i+=1
        #     elif nums[i]+nums[j]>target:
        #         j-=1
        # 方法二
        map ={}
        for i in range(len(nums)):
            need = target - nums[i]
            if need in map:
                return [i,map[need]]
            map[nums[i]] = i
        return  []

# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    print(solution.twoSum([2,5,5,11], 10))
    # your test code here